/*
Author: Tim Nguyen
Functionality: is a child to the Facility class so that 
		the building has the ability to have people escape
Version number: 0.0.1
Testers: needs to be tested
Date written: November 13th 2011
Date tested: needs to be tested
*/
package disease;

public class Subway extends Facilities{
    private double randomNumber;
    private double infectionChance;
    private int trains = 4;
    private static boolean maxLevel = false;
    
    public Subway(String type,int randomNum) {
        super(type);
        randomNumber = randomNum; // a random number will be passed in 
        							      // when creating an instance of this class
        infectionChance = 1.0;  //100% if bitten will be turned to a zombie
    }
    
    public boolean upgradeSubway(){
    	if (on == true && trains < 8){
    		System.out.println("upgrade subway successful");
    		super.upgradeBuilding();
    		trains += 1;
    		infectionChance -= 0.1;
        	return true;
    	}
    	else if (on == false){
    		System.out.println("cannot upgrade: closed");
    		return false;
    	}
    	else{
    		System.out.println("Cannot upgrade further");
    		maxLevel = true;
    		return false;
    	}
    	
    }
    
    public int peopleEscape() {
	    int savedPeople = 1;
	    	savedPeople *= trains*(int)randomNumber;
	    	savedPeople -= savedPeople*infectionChance;
	    	return savedPeople;
	    }
	
	public double getInfectionChance(){
		return infectionChance;
	}
	
    public boolean canUpgrade(){
    	return !maxLevel;
    }
    public boolean getMaxLevel(){
    	return maxLevel;
    }
}